<?php //2017-6-27
header("Content-type: image/jpeg");
$src = imagecreatetruecolor(400, 200);
$color = imagecolorallocate($src, 0,0,0);
imageFill($src,0,0,$color);


$color1 = imagecolorallocate($src,mt_rand(20,255),mt_rand(20,255),mt_rand(20,255));
$color2 = imagecolorallocate($src,mt_rand(20,255),mt_rand(20,255),mt_rand(20,255));
imagerectangle($src, 10, 50, 200, 150, $color1); //空心矩形 前两个值为开始 后为结束
imagefilledrectangle($src, 20, 60, 190, 140, $color2);//实心矩形 前两个值为开始 后为结束
imageellipse($src, 300, 100, 190, 190, $color1); //空心圆 前两个值为圆的中心点位置 后圆的半径
imagefilledellipse($src, 300, 100, 170, 170, $color2); //实心圆 前两个值为圆的中心点位置 后圆的半径
imageline($src, 300, 100, 170, 170, $color2); //绘制线条  前两个值为开始 后为结束
imagesetpixel($src, 20, 180, $color2); //绘制单一像素

//imagettftext($src, 55, 10, 240, 140, $color2, './FireBlock.ttf', 'Abc'); //用特殊字体输入文本 坐标位置为左下角
//imagettftext($src, 55, 10, 40, 140, $color2, './FireBlock.ttf', 'Abc');
for ($i=0; $i < 4 ; $i++) { 
	$w = $i*35;
	$w+= 25;
	$texts = "qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM1234567890";
	$text = $texts[mt_rand(0,strlen($texts)-1)];
	$color2 = imagecolorallocate($src,mt_rand(20,255),mt_rand(20,255),mt_rand(20,255));
	imagettftext($src, 50, mt_rand(-20,20), $w, mt_rand(120,135), $color2, './FireBlock.ttf', $text);
}

for ($i=0; $i < 300 ; $i++) {
	$color2 = imagecolorallocate($src,mt_rand(20,255),mt_rand(20,255),mt_rand(20,255));
	imagesetpixel($src, mt_rand(0,400),mt_rand(0,200), $color2);
}

for ($i=0; $i < 12 ; $i++) { //随机生成线条前面两个控制上部分 后两控下
	$color2 = imagecolorallocate($src,mt_rand(20,255),mt_rand(20,255),mt_rand(20,255));
	imageline($src, mt_rand(20,200), mt_rand(60,150), mt_rand(30,190), mt_rand(70,140), $color2);
}




imagejpeg($src);
//imagejpeg($src,'./new.jpg');


//图像输出完毕及时释放资源，把内存空间留给更需要的程序
imageDestroy($src);
	
 ?>